package com.group5.service;

import com.group5.pojo.*;

import java.awt.*;


public class BuyerService {
    public UserssExample getEmployeesBySellerOid(Integer oid){
        UserssExample userssExample = new UserssExample();
        userssExample.createCriteria().andOidEqualTo(oid).andIs_organization_acceptEqualTo(1);
        return userssExample;
    }

    /**
     * 下面的方法写错地方了.是卖方的方法,但是本身运行是没有问题的,我就不改了
     * @param uid 卖方员工uid
     * @return  卖方员工对于分组情况
     */
    public GroupsAndEmployeesExample getEmployeesAndGroupByUid(Integer uid){
        GroupsAndEmployeesExample groupsAndEmployeesExample=new GroupsAndEmployeesExample();
        groupsAndEmployeesExample.createCriteria().andUidEqualTo(uid);
        return groupsAndEmployeesExample;
    }
    public GroupsAndEmployeesExample getEmployeesAndGroupByoid(Integer oid){
        GroupsAndEmployeesExample groupsAndEmployeesExample=new GroupsAndEmployeesExample();
        groupsAndEmployeesExample.createCriteria().andOidEqualTo(oid);
        return groupsAndEmployeesExample;
    }

  public GroupAndCustomerExample selectByBuyerAndSellerOid(int boid,int soid){
        GroupAndCustomerExample groupAndCustomerExample = new GroupAndCustomerExample();
        groupAndCustomerExample.or(groupAndCustomerExample.createCriteria().andBuyer_oidEqualTo(boid).andSeller_oidEqualTo(soid));
        return groupAndCustomerExample;
    }

    public UserssExample selectUserByUsernameExample(String username) {
        UserssExample userssExample=new UserssExample();
        userssExample.createCriteria().andUser_nameEqualTo(username);
        return userssExample;
    }

    public void initUser(Userss userss) {
        userss.setOid(null);
        userss.setUser_authority(1);
        userss.setIs_organization_accept(0);
    }
}

